<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>组织管理/重置密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>
    <div class="layui-form" lay-filter="">
        <table class="table-detail" style="margin-top: 10px">
            <tr>
                <th>密码:</th>
                <td><input type="password" name="password"  lay-verify="required" placeholder="请输入密码"
                        autocomplete="off" class="layui-input" maxlength="50" style="display:inline-block">
                    <table class="pwdLever">
                        <tr>
                            <td>弱</td>
                            <td>中</td>
                            <td>强</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <th>确认密码:</th>
                <td><input type="password" name="passwordNew"  lay-verify="required" placeholder="请输入密码"
                        autocomplete="off" class="layui-input" maxlength="50" style="display:inline-block">
                </td>
            </tr>
        </table>
        <div style="text-align: center">
            <button class="layui-btn btn-n" lay-submit lay-filter="setmypass" style="margin:18px 10px" type="button">保存</button>
            <button class="layui-btn btn-n layui-btn-danger cancelPassword" style="margin:18px 10px" type="button">取消</button>
        </div>
    </div>
    <script src="${ctx}/public/component.js" type="text/javascript"></script>
    <script src="${ctx}/layui/layui.js"></script>
    <script>
        layui.config({
            base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index','layer',  'setter','commons','form','jquery'], function() {
            var setter=layui.setter,commons=layui.commons,form = layui.form,$=layui.jquery;
            var userId = '${userId}';//修改
            var num;//首次输入密码
            //密码强弱判断
            $("input[name='password']").keyup(function(){
                num=this.value;
                commons.pwdChangenum(commons.pwdChange(num))
            });
            form.on('submit(setmypass)', function(obj){
                var numOne=$("input[name='passwordNew']").val();
                if(num!=numOne){
                    layer.msg('两次密码输入不一致，请重新输入')
                }else{
                    obj.field.userId = userId;
                    $.ajax({
                        url: serverPath.systemPath + setter.sysLinkPath + "sysUser/resetPwd",
                        type: "post",
                        dataType: 'json',
                        data:obj.field,
                        success: function (data) {
                            if (commons._filterRecord(data)) {
                                layer.alert(data.msg, function (index) {
                                    layer.close(index);
                                    parent.layui.table.reload('userListTable',{page:{curr:1}});
                                    parent.layui.totalFilter.init('userListTable');
                                    parent.window.Initialization();
                                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                                });
                            } else {
                               layer.alert(data.msg);
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert("暂无数据，请稍后操作！" + XMLHttpRequest.status);
                        }
                    });
                }
            })
            $(".btn-n.cancelPassword").click(function () {//取消
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            })

        })

    </script>
</body>
</html>